<template>
	<gui-page :customHeader="true" :headerClass="['gui-bg-white']" ref="guiPage" :fullPage="true">
		<!-- 自定义头部导航 -->
		<template v-slot:gHeader>
			<view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
				<!-- 使用组件实现返回按钮及返回首页按钮 -->
				<gui-header-leading :home="false"></gui-header-leading>
				<!-- 导航文本此处也可以是其他自定义内容 -->
				<view style="width:44rpx;"></view>
				<text class="gui-flex1 gui-text-center gui-ellipsis">班长审批</text>
				<!-- 此处加一个右侧展位元素与左侧同宽，实现标题居中 -->
				<!-- 实际宽度请根据自己情况设置 -->
				<view style="width:120rpx;"></view>
				<!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
			</view>
		</template>

		<template v-slot:gBody>
			<view class="gui-relative">
				<view class="hulu-main">
					<view class="gui-padding">
						<text class="gui-text gui-color-black">流程环节</text>
					</view>
					<view class="gui-padding-x gui-bg-white" v-if="ticket.processes&&ticket.processes.length>0">
						<up-steps :current="currentStep" direction="column">
							<up-steps-item :title="t.comment" :desc="t.created_at" v-for="(t,index) in ticket.processes"
								:key="index">
							</up-steps-item>
						</up-steps>
					</view>
					<view class="gui-padding">
						<text class="gui-text gui-color-black">维修信息</text>
					</view>
					<view class="gui-padding-x gui-bg-white">
						<view class="bill-content">
							<view class="" style="height:24rpx;">
				
							</view>
							<view class="bill-content-main">
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">图片</text>
								<view class="content-imgs gui-margin">
									<view class="content-img" v-if="ticket.repair" v-for="(r,i) in ticket.repair.images"
										:key="i">
										<image @tap="onTapImage(i)" :src="r" mode="aspectFill"
											style="width:168rpx;height:168rpx;"></image>
									</view>
								</view>
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">摘要</text>
								<view class="content-feather hulu-font-5 gui-margin">
									<view class="hulu-text-color4" v-if="ticket.repair">
										{{ticket.repair.user_name}}
										{{ticket.repair.phone}}
										{{ticket.repair.license}}
										{{ticket.repair.description}}
										{{ticket.repair.created_at}}
										{{ticket.repair.address}}
									</view>
								</view>
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">项目</text>
								<view class="content-feather hulu-font-5 gui-margin">
									<view v-if="ticket" v-for="(s,index) in ticket.services" :key="index">{{s.name}}x️1
									</view>
								</view>
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">维修工</text>
								<view class="content-price">
									<view class="gui-flex gui-justify-content-start gui-margin">
										<text class="hulu-text-color3" v-if="ticket" v-for="(u,idx) in ticket.users"
											:key="idx">
											{{u.name}}
										</text>
									</view>
								</view>
								<text class="hulu-font-4 hulu-text-color7 gui-color-black">工位</text>
								<view class="content-price">
									<view class="gui-flex gui-justify-content-start gui-margin">
										<text class="hulu-text-color1" v-if="ticket.parking">
											{{ticket.parking.parking_type}}{{ticket.parking.no}}
										</text>
									</view>
								</view>
							</view>
							<view class="" style="height:24rpx;">
				
							</view>
						</view>
					</view>
				
					<view class="gui-padding">
						<text class="gui-text gui-color-black">最终工时</text>
					</view>
					<view class="gui-padding gui-bg-white">
						<view
							class="gui-flex gui-rows gui-nowrap gui-border-l  gui-border-t hulu-primary-bg-color1 gui-dark-bg-level-2">
							<text
								class="gui-td gui-border-r gui-border-b gui-primary-text hulu-text-color7 gui-text-center">单号</text>
							<text
								class="gui-td gui-border-r gui-border-b gui-primary-text hulu-text-color7 gui-text-center">维修工ID</text>
							<text
								class="gui-td gui-border-r gui-border-b gui-primary-text hulu-text-color7 gui-text-center">工时</text>
						</view>
						<view class="gui-flex gui-rows gui-nowrap gui-border-l" v-for="(item, index) in ticket.records"
							:key="index">
							<text
								class="gui-td gui-primary-text gui-text-center gui-border-r gui-border-b">{{item.id}}</text>
							<text
								class="gui-td gui-primary-text gui-text-center gui-border-r gui-border-b">{{item.user_id}}</text>
							<text
								class="gui-td gui-primary-text gui-text-center gui-border-r gui-border-b">{{item.score}}</text>
				
						</view>
					</view>
					<view class="gui-padding">
						<text class="gui-text gui-color-black">工位占用</text>
					</view>
					<view class="gui-padding gui-bg-white" v-if="ticket.parking">
						<view
							class="gui-flex gui-rows gui-nowrap gui-border-l gui-border-t hulu-primary-bg-color1 gui-dark-bg-level-2">
							<text
								class="gui-td gui-border-r gui-border-b gui-primary-text hulu-text-color7  gui-text-center">工位ID</text>
							<text
								class="gui-td gui-border-r gui-border-b gui-primary-text hulu-text-color7 gui-text-center">时间</text>
							<text
								class="gui-td gui-border-r gui-border-b gui-primary-text hulu-text-color7 gui-text-center">状态</text>
						</view>
						<view class="gui-flex gui-rows gui-nowrap gui-border-l"
							v-for="(s, index) in ticket.parking_states" :key="index">
							<text
								class="gui-td gui-primary-text gui-text-center gui-border-r gui-border-b">{{s.parking_id}}</text>
							<text
								class="gui-td hulu-font-5 gui-text-center gui-border-r gui-border-b">{{s.created_at}}</text>
							<text
								class="gui-td gui-primary-text gui-text-center gui-border-r gui-border-b">{{s.state}}</text>
						
						</view>
					</view>
				</view>

				<view class="" style="height:180rpx;">

				</view>
				<view class="pay-btn" style="background-color: white;">
					<view class="" style="height:24rpx;">

					</view>
					<view class="pay-btn-warp">
						<view class="pay-action hulu-primary-bg-color1" hover-class="gui-tap" @tap="pass">
							同意
						</view>
					</view>
				</view>
				<view class="bottom-phone">

				</view>
			</view>
		</template>
	</gui-page>
</template>
<script>
	import useTicket from "@/api/ticket"
	import graceJS from '@/Grace6/js/grace.js';
	const {
		showTicket,
		ticketPass
	} = useTicket()
	export default {
		data() {
			return {
				currentStep: 0,
				ticket: {},
				id: null
			}
		},
		created() {},
		mounted() {},
		onLoad(option) {

			this.id = +(option.id)
			this.getTicket()
		},
		methods: {
			async getTicket() {
				const {
					data
				} = await showTicket(this.id)
				this.ticket = data
				this.currentStep = data.processes.length
			},
			async pass() {
				await ticketPass(this.id)
				setTimeout(() => {
					uni.reLaunch({
						url: `/pages/ticket/index`
					})
				}, 500)
			},
			unpass() {},
			onTapImage(i) {
				uni.previewImage({
					current: i + 1,
					urls: this.ticket.repair.images
				})
			}

		},
	}
</script>
<style lang="scss">
	.hulu-main {
		padding: 0 24rpx;
		box-sizing: border-box;
	}

	.bill-content {
		.bill-content-main {
			.content-imgs {
				display: flex;
				justify-content: space-around;

				.content-img {
					-webkit-box-shadow: 0px -2px 12px 0px rgba(0, 0, 0, 0.2);
					-moz-box-shadow: 0px -2px 12px 0px rgba(0, 0, 0, 0.2);
					box-shadow: 0px -2px 12px 0px rgba(0, 0, 0, 0.2);
				}
			}


			.content-feather {
				display: flex;
				flex-direction: column;
				justify-content: flex-start;
				align-items: flex-start;
			}

			.content-price {
				font-size: 22rpx;
			}
		}
	}

	.gui-td {
		width: 100rpx;
		flex: 1;
		overflow: hidden;
		padding: 10rpx 10rpx;
		display: flexbox;
	}

	.gui-primary-text {
		line-height: 60rpx !important;
		font-size: 24rpx;
	}

	.pay-btn {
		height: 128rpx;
		background-color: white;
		position: fixed;
		bottom: 68rpx;
		width: 100%;
		box-sizing: border-box;

		.pay-btn-warp {
			padding: 0 36rpx;

			display: flex;
			justify-content: space-between;
			align-items: center;



			.pay-action {
				width: 700rpx;
				height: 76rpx;
				border-radius: 38rpx;
				font-size: 32rpx;
				line-height: 76rpx;
				text-align: center;
				color: white;
				font-weight: bold;
			}

			.unpass {
				width: 300rpx;
			}
		}
	}

	.bottom-phone {
		width: 750rpx;
		height: 68rpx;
		background-color: white;
		bottom: 0;
		position: fixed;
	}
</style>